﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using MyCommon;

namespace BussinessLayer
{
    public class KhachHangBO : BaseBO
    {
        #region Singleton implemented
        private static KhachHangBO _instance;
        private KhachHangBO()
        {}
        public static KhachHangBO getInstance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new KhachHangBO();
                }
                return _instance;
            }
        }
#endregion

        public IEnumerable<KhachHang> GetAllKhachHang()
        {
            return _dao.KhachHang.GetAllKhachHang();
        }
        public KhachHang GetKhachHangById(int id)
        {
            return _dao.KhachHang.GetKhachHangById(id);
        }
        public bool UpdateKhachHang(KhachHang inKhachHang)
        {
            return _dao.KhachHang.UpdateKhachHang(inKhachHang);
        }
        public bool InsertKhachHang(KhachHang inKhachHang)
        {
            return _dao.KhachHang.InsertKhachHang(inKhachHang);
        }
        public ReturnValue<bool> DelKhachHang(int id)
        {
            return _dao.KhachHang.DelKhachHang(id);
        }
        public string GenerateMaKhachHang()
        {
            KhachHang aObj = _dao.KhachHang.GetLastRecord();
            if (aObj != null)
            {
                return Utils.GenerateCode(CodeType.KhachHang, aObj.Id + 1);
            }
            else
            {
                return Utils.GenerateCode(CodeType.KhachHang, 1);
            }
        }
        public KhachHang GetLastRecord()
        {
            return _dao.KhachHang.GetLastRecord();
        }

        public IEnumerable<KhachHang> GetDsKhachHangWithFilter( string inMaKH = "", string inTenKhachHang = "")
        {
            return _dao.KhachHang.GetDsKhachHangWithFilter(inMaKH, inTenKhachHang);
        }

    }
}
